# 字体格式的设置
# 设置字符格式：包括字体（name）和大小(size)、粗体(bold)、斜体(italic)和下划线(underline)

from docx import Document
from docx.shared import RGBColor, Pt
from docx.enum.dml import MSO_THEME_COLOR_INDEX
from docx.enum.text import WD_UNDERLINE
document = Document()
paragraph = document.add_paragraph()
run1 = paragraph.add_run('字体颜色设置')

font = run1.font
# font.color.rgb = RGBColor(100, 230, 100)
font.color.theme_color = MSO_THEME_COLOR_INDEX.ACCENT_1
font.size = Pt(20)  # 1 英寸 = 2.54 厘米  = 72磅 = 914400英国公制
font.italic = True
font.bold = True
font.underline = WD_UNDERLINE.DOUBLE

document.save('格式设置.docx')
